// 封装banner轮播图相关的业务代码

import { onMounted, ref } from "vue";
// 引入获取轮播图API
import { getBannerAPI } from "@/apis/home";

export function useBanner() {
  // 定义轮播图数据列表
  const bannerList = ref([]);

  // 获取分类banner -- distributionSite = 2
  const getBanner = async () => {
    const res = await getBannerAPI({
      distributionSite: 2,
    });
    //console.log(res);
    bannerList.value = res.result;
  };

  // 组件挂在后自动获取轮播图数据
  onMounted(() => getBanner());

  return {
    bannerList,
  };
}
